﻿using System;
using System.Collections.Generic;
using System.Text;
using WebHacker;
using mshtml;

namespace ECC_EXT_HttpLib
{
    class MerchandiseName : WebHacker.XMLHttpForm
    {
        public MerchandiseName()
        {
            __VIEWSTATE = "";
            Hidden1 = "";
            txtSKU = "";
            btnKensaku = "";
            txtMousikomiNum = "";
            __EVENTVALIDATION = "";
        }


        public string __VIEWSTATE { get; set; }
        public string Hidden1 { get; set; }
        public string txtSKU { get; set; }
        public string btnKensaku { get; set; }
        public string txtMousikomiNum { get; set; }
        public string __EVENTVALIDATION { get; set; }

    }

    public class SearchMerchandiseName
    {
        public static string GetName(string pMerchandiseNo)
        {
            WebTools wt  = new WebTools();
            String vLink = "http://svfile05/scripts/MDISS_WebUI/SKUInfo/INTSKU0/intSKU0.aspx";

            mshtml.HTMLDocument hd =
            wt.HttpRequest(vLink,new RequestHeaders());

            MerchandiseName tt = new MerchandiseName();
            tt.__VIEWSTATE = Utility.GetAttributeById(hd, "__VIEWSTATE", "value");
            tt.__EVENTVALIDATION = Utility.GetAttributeById(hd, "__EVENTVALIDATION", "value");
            tt.txtMousikomiNum = pMerchandiseNo;

            hd =
            wt.SubmitFormData(vLink, tt.ToString());
            HTMLDivElementClass hdec =
            hd.getElementById("MechandisePanel") as HTMLDivElementClass;

            HTMLTableRowClass  tmp1=
                hdec.firstChild.firstChild.firstChild as HTMLTableRowClass;
            HTMLTableCellClass tmp2 =
                tmp1.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild as HTMLTableCellClass;

            return tmp2.innerText;
        }
    }
}
